package com.uzai.common.utils;

import java.util.Arrays;
import java.util.List;

/**
 * @author jianghan
 * @date 2022/5/24 11:21
 */
public class MqDelayLevelUtil {
    // 1s 2s 3s 4s 5s 6s 7s 8s 9s 10s 20s 1m 5m 10m 20m 1h 2h 3h
    private final static List<Integer> levels = Arrays.asList(
            10800,
            7200,
            3600,
            1200,
            600,
            300,
            60,
            20,
            10,
            9,
            8,
            7,
            6,
            5,
            4,
            3,
            2,
            1
    );

    public static MqDelayLevel getLevel(int time) {
        MqDelayLevel mqDelayLevel = new MqDelayLevel();
        for (int i=0;i<levels.size();i++){
            if (levels.get(i).intValue()<=time){
                mqDelayLevel.setLevel(levels.size()-i);
                mqDelayLevel.setDelay(levels.get(i));
                break;
            }
        }
        return mqDelayLevel;
    }
}
